<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>查找 &amp; 替换</title>
  <link href="../Styles/styles.css" rel="stylesheet" type="text/css"/>
</head>

<body>
  <h2 id="find_and_replace">查找 &amp; 替换</h2>

  <p class="h2subheading">— 在代码视图中搜索 —</p>

  <p>Finding text and updating it is one of the most common tasks in Sigil – to look for words, to remove unwanted text in one file, or to change the formatting of specific items in the entire book. In fact, if you ever need to make lots of changes to your text you will almost certainly want to use Find &amp; Replace (and its related <a href="../Text/saved_searches.html">Saved Searches</a> feature) since it allows you to quickly make a large number of edits across all your files.</p>
  <p>查找文本并对其进行更新是 Sigil 中最常见的任务之一-查找单词，删除一个文件中不需要的文本或更改整本书中特定项目的格式。实际上，如果您需要对文本进行大量更改，则几乎可以肯定要使用“查找 &amp; 替换”（及其相关的 <a href="../Text/saved_searches.html">保存的搜索</a> 功能），因为它允许您快速对所有文件进行大量修改。</p>

  <div class="tip">
    <p class="tiptext">See the <a href="../Text/tutorial_regex_reference.html">Regex</a> tutorial for information about advanced searching.</p>
    <p class="tiptext">有关高级搜索的信息，请参见 <a href="../Text/tutorial_regex_reference.html">Regex</a> 教程。</p>
  </div>

  <p>To open the Find &amp; Replace dialog, select the menu item <span class="menuitem">Search→Find &amp; Replace</span> or its keyboard shortcut:</p>
  <p>要打开“查找 &amp; 替换”对话框，请选择菜单项 <span class="menuitem">搜索→查找 &amp; 替换</span> 或其键盘快捷键：</p>

  <div class="image">
    <img alt="find-replace-options" src="../Images/find-replace-options.png"/>
  </div>

  <p>You can set various modes (Normal, Case-Sensitive, Regex, search some or all HTML files or just selected text, search down/up, etc.) and options (Wrap, DotAll, etc.) to modify the behaviour of the actions (find, replace, replace all, etc.) you select, e.g.:</p>
  <p>您可以设置各种模式（常规，区分大小写，正则表达式，搜索部分或全部 HTML 文件或仅搜索选定文本，向下/向上搜索等）和选项（环绕，DotAll 等）来修改动作的行为（查找，替换，全部替换等），例如：</p>

  <div class="image">
    <img alt="find-replace-options-example" src="../Images/find-replace-options-example.png"/>
  </div>

  <p>When open, the Find &amp; Replace dialog is always positioned at the bottom of the editing window for easy access. You can use the buttons on the lower left to show or hide Options.</p>
  <p>打开后，“查找 &amp; 替换”对话框始终位于编辑窗口的底部，以方便访问。您可以使用左下方的按钮显示或隐藏选项。</p>

  <div class="tip">
    <p class="tiptext">Keyboard shortcuts exist for all find and replace operations – such as <span class="shortcut">Ctrl+G</span> to find again. See the <span class="menuitem">Search</span> menu for a list of shortcuts.</p>
    <p class="tiptext">存在所有查找和替换操作的键盘快捷键，例如 <span class="shortcut">Ctrl+G</span> 可以再次查找。请参阅 <span class="menuitem">搜索</span> 菜单以获取快捷方式列表。</p>
  </div>

  <h3 class="sigil_not_in_toc" id="find_actions">操作</h3>

  <p>The buttons on the right are used to run your search commands.</p>
  <p>右侧的按钮用于运行搜索命令。</p>

  <div class="tip">
    <p class="tiptext">After you run a search, the text you entered in either the Find or Replace box is saved and is available for you to select later. Click the down-arrow to the right of the Find (or Replace) text box to show the list of items in the search histories.</p>
    <p class="tiptext">运行搜索后，在“查找”或“替换”框中输入的文本将被保存，供以后选择。 单击“查找（或替换）”文本框右侧的向下箭头，以显示搜索历史记录中的项目列表。</p>

    <p class="tiptext">Whenever you run a search, the results are shown in the Find &amp; Replace status bar.</p>
    <p class="tiptext">只要您运行搜索，结果就会显示在“查找 &amp; 替换”状态栏中。</p>
  </div>

  <h4 class="sigil_not_in_toc">查找</h4>

  <p>Finds the next occurrence of your search term and highlights it.</p>
  <p>查找搜索词的下一个出现并将其突出显示。</p>

  <p>To search for text, enter it in the Find text box and press the <span class="buttonbox">Find</span> button. Any text in the Replace box is ignored if you are just doing a Find.</p>
  <p>要搜索文本，请在“查找”文本框中输入文本，然后按 <span class="buttonbox">查找</span> 按钮。 如果您只是在查找，则“替换”框中的所有文本都将被忽略。</p>

  <div class="tip">
    <p class="tiptext">If you select text in your document, you can use <span class="shortcut">Ctrl+F</span> to open Find &amp; Replace window and your selected text will be placed in the Find box.</p>
    <p class="tiptext">如果您选择文档中的文本，则可以使用 <span class="shortcut">Ctrl+F</span> 打开“查找 &amp; 替换”窗口，您选择的文本将放置在“查找”框中。</p>
  </div>

  <h4 class="sigil_not_in_toc">替换</h4>

  <p>Replaces one occurrence of the text matched by Find.</p>
  <p>替换出现一次与“查找”匹配的文本。</p>

  <div class="tip">
    <p class="tiptext">Replaces are done in Code View so you must first run Find in Code View.</p>
    <p class="tiptext">替换是在代码视图中完成的，因此您必须首先运行在代码视图中的查找。</p>
  </div>

  <p>替换文字：</p>

  <ul>
    <li>Enter the text to find in the Find box.</li>
    <li>在“查找”框中输入要查找的文本。</li>

    <li>Enter the text you want to replace it with in Replace box.</li>
    <li>在“替换”框中输入要替换为的文本。</li>

    <li>Select <span class="buttonbox">Find</span> to search for and highlight a match.</li>
    <li>选择 <span class="buttonbox">查找</span> 以搜索并突出显示匹配项。</li>

    <li>Select <span class="buttonbox">Replace</span> to do the replacement.</li>
    <li>选择 <span class="buttonbox">替换</span> 进行替换。</li>
  </ul>

  <div class="tip">
    <p class="tiptext">To undo changes you can use the Undo button <img alt="" src="../Images/edit-undo_22px.png"/> or right-click in the editing window and select <span class="menuitem">Undo</span> to change the text back. But if you are replacing across files and your next match is on a different page, you need to switch back to the file containing the replaced text before selecting undo.</p>
    <p class="tiptext">要撤消更改，可以使用“撤消”按钮 <img alt="" src="../Images/edit-undo_22px.png"/> 或在编辑窗口中右键单击并选择 <span class="menuitem">撤消</span> 将文字改回原位。但是，如果要跨文件替换文件，而下一个匹配项在另一个页面上，则需要在选择撤消之前切换回包含替换文本的文件。</p>
  </div>

  <h4 class="sigil_not_in_toc">替换/查找</h4>

  <p>Replaces one occurrence of the next matched by Find and then runs Find automatically to highlight the next match.</p>
  <p>用查找替换下一个匹配项的一个匹配项，然后自动运行查找以突出显示下一个匹配项。</p>

  <p>To replace text, enter the old text in the Find box, and the new text in the Replace box. Then click <span class="buttonbox">Replace/Find</span>.</p>
  <p>要替换文本，请在“查找”框中输入旧文本，然后在“替换”框中输入新文本。然后单击 <span class="buttonbox">替换/查找</span>。</p>

  <p>The first time you do a <span class="buttonbox">Replace/Find</span> the first match will be highlighted. Subsequent use of <span class="buttonbox">Replace/Find</span> will replace the highlighted matched text and then automatically Find the next match.</p>
  <p>第一次执行 <span class="buttonbox">替换/查找</span> 时，第一个匹配项将突出显示。随后使用 <span class="buttonbox">替换/查找</span> 将替换突出显示的匹配文本，然后自动查找下一个匹配项。</p>

  <div class="tip">
    <p class="tiptext">You can safely use Replace/Find instead of Find if no text is selected since it will act just like Find until a match is highlighted.</p>
    <p class="tiptext">如果未选择任何文本，则可以安全地使用“替换/查找”代替“查找”，因为在突出显示匹配项之前，它的作用与“查找”相同。</p>
  </div>

  <h4 class="sigil_not_in_toc">全部替换</h4>

  <p>Replaces all text matching your search term with your replace term according to your settings. This is done all at once automatically.</p>
  <p>根据您的设置，将所有与搜索词匹配的文本替换为替换词。这是自动一次完成的。</p>

  <div class="tip">
    <p class="tiptext">You cannot undo a Replace All – save first!</p>
    <p class="tiptext">您不能撤消全部替换——先保存！</p>
  </div>

  <p><span class="buttonbox">Replace All</span> always replaces from the start of a file.</p>
  <p><span class="buttonbox">全部替换</span> 始终从文件开头开始替换。</p>

  <div class="tip">
    <p class="tiptext">Test your find and replace strings using Count All, or Replace a few times before using Replace All to avoid surprises.</p>
    <p class="tiptext">使用“全部计数”测试查找和替换字符串，或者在使用“全部替换”之前几次替换，以免引起意外。</p>

    <p class="tiptext">Save your book before a Replace All and check it after the replace in case of issues.</p>
    <p class="tiptext">请在“全部替换”之前保存您的图书，并在替换后检查以防万一。</p>

    <p class="tiptext">Check if your mode is set for <span class="buttonbox">Current File</span> or <span class="buttonbox">All HTML Files</span></p>
    <p class="tiptext">检查您的模式是否设置为 <span class="buttonbox">当前文件</span> 或 <span class="buttonbox">所有 HTML 文件</span></p>
  </div>

  <h4 class="sigil_not_in_toc" id="count_all">全部计数</h4>

  <p>Count All can be displayed using the Options button (see below) – or you can use its keyboard shortcut.</p>
  <p>可以使用“选项”按钮（请参阅下文）显示全部计数——或使用其键盘快捷键。</p>

  <p>Count All displays a count of the number of times the search term you entered in the Find text box occurs in the selected files. It uses the settings of both the Up/Down modes and the Wrap option.</p>
  <p>“全部计数”显示您在“查找”文本框中输入的搜索词在所选文件中出现的次数的计数。它使用“上/下”模式和“环绕”选项的设置。</p>

  <div class="tip">
    <p class="tiptext">It’s a good idea to use <span class="buttonbox">Count All</span> before doing a replace to check the number of replacements are what you expect. And you should run it after a Replace All in case the particular search and replace created new matches.</p>
    <p class="tiptext">最好在进行替换之前使用 <span class="buttonbox">全部计数</span> 来检查替换次数是否符合您的期望。 并且您应该在全部替换之后运行它，以防特定搜索和替换创建新的匹配项。</p>
  </div>

  <h3 class="sigil_not_in_toc" id="find_what">模式 - 搜索内容</h3>

  <p>You can control what type of text to search for using these options.</p>
  <p>您可以使用这些选项控制要搜索的文本类型。</p>

  <h4 class="sigil_not_in_toc">标准</h4>

  <p>This mode will search for exactly what you type except that it will ignore case, e.g. “A” and “a” will be considered the same letter.</p>
  <p>此模式将完全搜索您键入的内容，但会忽略大小写，例如 “A”和“a”将被视为同一字母。</p>

  <h4 class="sigil_not_in_toc">区分大小写</h4>

  <p>This mode will search for exactly what you type.</p>
  <p>此模式将精确搜索您键入的内容。</p>

  <h4 class="sigil_not_in_toc">正则表达式</h4>

  <p>Regex is an abbreviation of “Regular Expression”. This mode allows you to search for patterns instead of exact words or characters. Regex is very powerful and one of the main benefits of using Sigil to work with ebooks.</p>
  <p>正则表达式是“正则表达式”的缩写。 此模式允许您搜索模式，而不是精确的单词或字符。正则表达式非常强大，并且是使用 Sigil 与电子书一起使用的主要好处之一。</p>

  <p>For instance, you can search for “Page [0-9]+” which will find "Page " followed by one or more numbers.</p>
  <p>例如，您可以搜索“页面[0-9]+”，该页面将找到“页面”后跟一个或多个数字。</p>

  <div class="tip">
    <p class="tiptext">See the <a href="../Text/tutorial_regex_reference.html">Regular Expressions</a> chapter for more details about using regex.</p>
    <p class="tiptext">有关使用正则表达式的更多详细信息，请参见 <a href="../Text/tutorial_regex_reference.html">正则表达式</a> 一章。</p>
  </div>

  <h4 class="sigil_not_in_toc">模式 - 搜索位置</h4>

  <p>You can control which files to search with these options making it easy to search all or just some of your files.</p>
  <p>您可以使用这些选项控制要搜索的文件，从而可以轻松搜索全部或部分文件。</p>

  <h4 class="sigil_not_in_toc">当前文件</h4>

  <p>This restricts your search to just the file you are viewing. You can search HTML files and Style files.</p>
  <p>这会将您的搜索限制为仅正在查看的文件。您可以搜索 HTML 文件和样式文件。</p>

  <p>If your search reaches the end of the file and wrap is on it will automatically wrap around and search from the other end of the file. You will see a small picture of an arrow flash on the screen to indicate the search wrapped around.</p>
  <p>如果您的搜索到达文件末尾并且自动换行，它将自动换行并从文件的另一端开始搜索。您将在屏幕上看到一小幅箭头闪烁的箭头，指示搜索被环绕。</p>

  <div class="tip">
    <p class="tiptext">If you hold the <span class="shortcut">Ctrl</span> key down while clicking on an action you will be able to temporarily run the search only on the Current File.</p>
    <p class="tiptext">如果在单击操作时按住 <span class="shortcut">Ctrl</span> 键，则只能在“当前文件”上临时运行搜索。</p>
  </div>

  <h4 class="sigil_not_in_toc">所有 HTML 文件</h4>

  <p>This searches in every HTML file. It does not search in every file – just every HTML file.</p>
  <p>这会在每个 HTML 文件中搜索。它不会在每个文件中搜索——而是在每个 HTML 文件中搜索。</p>

  <p>When a search reaches the end or beginning of the book it will automatically move to the next or previous file (in the order listed in the book browser), and it will loop around when all files have been searched if wrap is on.</p>
  <p>当搜索到达书的结尾或开头时，它将自动移至下一个或上一个文件（按书浏览器中列出的顺序），并且如果打开了换行功能，则在搜索完所有文件时将循环查找。</p>

  <h4 class="sigil_not_in_toc">选定的 HTML 文件</h4>

  <p>This searches only the HTML files that you selected in the Book Browser.</p>
  <p>这仅搜索您在“书籍浏览器”中选择的 HTML 文件。</p>

  <p>When a search reaches the end of a file it will automatically move to the next or previous selected file (in the order listed in the book browser), and it will loop around when all files have been searched if wrap is on.</p>
  <p>当搜索到达文件末尾时，它将自动移动到下一个或上一个选定的文件（按书籍浏览器中列出的顺序），并且如果打开了换行功能，则在搜索完所有文件时将循环显示。</p>

  <h4 class="sigil_not_in_toc">标记文本</h4>

  <p>This is a special option that is only shown when you mark text.</p>
  <p>这是一个特殊选项，仅在标记文本时才会显示。</p>

  <p>You can restrict your search to a selection of text by marking that text. To mark text, select some text in Code View and then use the <span class="menuitem">Search→Mark Selected Text</span> or use the right-click context menu to select <span class="menuitem">Mark Selected Text</span>.</p>
  <p>您可以通过标记文本来将搜索限制为选择文本。要标记文本，请在“代码视图”中选择一些文本，然后使用 <span class="menuitem">搜索→标记选定的文本</span>，或使用右键单击上下文菜单选择 <span class="menuitem">标记 选定的文本</span>。</p>

  <p>Text can be unmarked by using the menu item again without a selection.</p>
  <p>可以再次使用菜单项来取消标记文本，而无需进行选择。</p>

  <p>Text will be unmarked if you use Undo, type any text, or change tabs. If you just use Replace or Replace All, the marked text will be expanded or shrunk appropriately.</p>
  <p>如果您使用撤消，键入任何文本或更改选项卡，则文本将不带标记。如果仅使用“全部替换”或“全部替换”，则标记的文本将被适当地扩展或缩小。</p>

  <h3 class="sigil_not_in_toc">模式 - 搜索方向</h3>

  <p>You can control the direction of searching with these options.</p>
  <p>您可以使用这些选项控制搜索方向。</p>

  <h4 class="sigil_not_in_toc">向上</h4>

  <p>Searches from your position in the document upwards and finds the previous occurrence of your search.</p>
  <p>从您在文档中的位置向上搜索，并找到先前的搜索结果。</p>

  <h4 class="sigil_not_in_toc">向下</h4>

  <p>Searches from your position in the document downwards and finds the next occurrence of your search.</p>
  <p>从您在文档中的位置向下搜索，然后查找下一次搜索。</p>

  <h3 class="sigil_not_in_toc">选项</h3>

  <p>Find &amp; Replace provides several options when using Regex mode.</p>
  <p>使用正则表达式模式时，查找 &amp; 替换提供了几个选项。</p>

  <p>Click the show button <img alt="" src="../Images/chevron-down_16px.png"/> on the Find &amp; Replace window to expand the window if it’s not already expanded to show the options and the button <span class="buttonbox">Count All</span>:</p>
  <p>单击“查找 &amp; 替换”窗口上的显示按钮 <img alt="" src="../Images/chevron-down_16px.png"/>，以扩展该窗口（如果尚未扩展以显示选项）和按钮 <span class="buttonbox">全部计数</span>：</p>

  <div class="image">
    <img alt="find-replace-options" src="../Images/find-replace-options.png"/>
  </div>

  <p>Click the hide button <img alt="" src="../Images/chevron-up_16px.png"/> to hide the options:</p>
  <p>单击隐藏按钮 <img alt="" src="../Images/chevron-up_16px.png"/> 来隐藏选项：</p>

  <div class="image">
    <img alt="find-replace-basic" src="../Images/find-replace-basic.png"/>
  </div>

  <h4 class="sigil_not_in_toc">DotAll</h4>

  <p>This regex option prepends (?s) to all regex searches and is used when you want the ".*" pattern to match any character even across lines.</p>
  <p>此正则表达式选项会在所有正则表达式搜索之前加上 (?s)，并且当您希望“.*”模式甚至跨行匹配任何字符时使用。</p>

  <h4 class="sigil_not_in_toc">最小匹配</h4>

  <p>This regex option prepends (?U) to all regex searches and is used when you want a pattern to match the shortest occurrence instead of the longest match.</p>
  <p>此正则表达式选项在所有正则表达式搜索之前加 (?U)，并在您希望模式匹配最短匹配而不是最长匹配时使用。</p>

  <h4 class="sigil_not_in_toc">自动标记</h4>

  <p>When using Ctrl-F on selected text to add text to Find &amp; Replace, this will convert spaces to \s and escape certain characters so they are suitable for regex.</p>
  <p>在选定文本上使用 Ctrl-F 将文本添加到“查找 &amp; 替换”中时，这会将空格转换为 \s 并转义某些字符，因此它们适用于正则表达式。</p>

  <h4 class="sigil_not_in_toc">Wrap</h4>

  <p>When enabled, searches in the Current File will automatically wrap around from the bottom of the file to the top to look for your text (or the reverse if searching Up). When disabled, searches will stop at the end of the file.</p>
  <p>启用此选项后，“当前文件”中的搜索将自动从文件底部到顶部进行换行，以查找您的文本（如果搜索为“向上”，则相反）。禁用后，搜索将在文件末尾停止。</p>

  <p>When you are searching in All HTML Files, then when wrap is enabled if your search reaches the last HTML file the search will continue automatically from the first HTML file to look for your text (or the reverse if searching Up). When disabled, searches will stop at the last file in the book (or the first if searching Up).</p>
  <p>在“所有 HTML 文件”中搜索时，如果启用了自动换行功能（如果搜索到达最后一个 HTML 文件），则搜索将自动从第一个 HTML 文件继续以查找您的文本（如果搜索为 Up，则相反）。 禁用后，搜索将在书中的最后一个文件处停止（如果搜索为 Up，则在第一个文件处停止）。</p>

  <h3 class="sigil_not_in_toc">上下文菜单</h3>

  <p>If you right-click on the Find or Replace box you are given various options:</p>
  <p>如果右键单击“查找”或“替换”框，将为您提供各种选项：</p>

  <ul>
    <li><span class="listheading"><i>Saved Searches</i>:</span> A list of Saved Searches you can select to load into Find &amp; Replace.</li>
    <li><span class="listheading"><i>保存的搜索</i>：</span>您可以选择加载到“查找 &amp; 替换”中的“保存的搜索”列表。</li>

    <li><span class="listheading">Save Search:</span> Save this Find &amp; Replace search in Saved Searches.</li>
    <li><span class="listheading">保存搜索：</span>在“保存的搜索”中保存此查找 &amp; 替换搜索。</li>

    <li><span class="listheading">Tokenise Selection:</span> Convert spaces to \s and escape certain characters.</li>
    <li><span class="listheading">标记选择：</span>将空格转换为 \s 并转义某些字符。</li>
  </ul>
</body>
</html>